package com.genesis.yunnanji.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;

import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.GeneralizeBean;
import com.youth.xframe.adapter.XRecyclerViewAdapter;
import com.youth.xframe.adapter.XViewHolder;

import java.util.List;

/**
 * 创建日期：2018/9/26 on 14:26
 * 作者:Kite
 * 描述:优惠卷Adapter
 */
public class GeneralizeAdapter extends XRecyclerViewAdapter<GeneralizeBean> {

    public GeneralizeAdapter(@NonNull RecyclerView mRecyclerView, List<GeneralizeBean> dataLists) {
        super(mRecyclerView, dataLists, R.layout.item_generalize);
    }

    @Override
    protected void bindData(XViewHolder holder, GeneralizeBean data, int position) {
        holder.setText(R.id.tv_price, data.getPrice());
        holder.setText(R.id.tv_title, data.getTitle());
        holder.setText(R.id.tv_conditions, data.getConditions());
        holder.setText(R.id.tv_time_limit, data.getTimeLimit());
        switch (data.getGeneralizeState()) {
            case 0:
                holder.setImageResource(R.id.iv_states, R.drawable.mycoupon_inget);//已领取
                holder.setText(R.id.tv_use,"去看一看");
                break;
            case 1:
                holder.setImageResource(R.id.iv_states, R.drawable.mycoupon_inchoice);//已选择
                holder.setText(R.id.tv_use,"立即使用");
                break;
            case 2:
                holder.setImageResource(R.id.iv_states, R.drawable.mycoupon_outget);//已领光
                holder.setText(R.id.tv_use,"已被领光");
                holder.setTextColor(R.id.tv_use,R.color.color_999);
                break;
            case 3:
                holder.setImageResource(R.id.iv_states, R.drawable.mycoupon_outofdate);//已过期
                holder.setText(R.id.tv_use,"已过期");
                holder.setTextColor(R.id.tv_use,R.color.color_999);
                break;
            case 4:
                holder.setVisible(R.id.iv_states, false);
                break;
        }
    }
}
